package com.example.oj.service;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CheckCodeSafe {
    public boolean checkCodeSafe(String templateCode){
        List<String> blackList = new ArrayList<>();
        blackList.add("Runtime");
        blackList.add("exec");
        blackList.add("java.io");
        blackList.add("java.net");
        blackList.add("while");
        blackList.add("for");
        for (String target:blackList) {
            int pos = templateCode.indexOf(target);
            if (pos >= 0){
                return false;
            }
        }
        return true;
    }
}
